package com.example.yunbiji0314.dao;

import com.example.yunbiji0314.pojo.Article;
import com.example.yunbiji0314.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ArticleDao {
    //根据用户id查询文章
    List<Article> findByUserId(Integer id);

    //删除文章
    @Update("update article set deleted = 1 where id = #{id}")
    int delete(Integer id);

    //根据文章id查询文章
    Article findById(Integer id);

    //添加文章
    @Insert("insert into article(title,content,state,cover_img,create_user,category_id) values(#{title},#{content},#{state},#{coverImg},#{createUser},#{categoryId})")
    int zengarticle(Article article);

    //修改文章内容
    int update(Article article);

    int batchSaveAccount(List<Article> articleList);

    List<Article> findByUserId02(Integer id);

    //根据分类id查询文章
    @Select("select * from article where category_id = #{id} and deleted = 0")
    List<Article> chabyid(Integer id);
}
